﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MTC.Web.Business.DTO;

namespace MTC.Web.Business
{
    public class Schedule
    {
        private List<ScheduleEntity> _scheduleEntityList = new List<ScheduleEntity>();
        
        public List<ScheduleEntity> GetSchedules()
        {
            List<MTC.Common.DTO.Schedule> schedules;
            schedules = MTC.Business.Schedule.Schedule.GetSchedules();
            if (schedules == null)
                return null;
            _scheduleEntityList.Clear();
            foreach (MTC.Common.DTO.Schedule schedule in schedules)
            {
                ScheduleEntity entity = new ScheduleEntity();
                entity.ScheduleId = schedule.ScheduleId;
                _scheduleEntityList.Add(entity);
            }
            return _scheduleEntityList;
        }

        public List<ScheduleEntity> GetASchedule(DateTime scheduleDate, int shiftId)
        {
            if (scheduleDate.ToString() == "1/01/0001 12:00:00 AM")
            return null;
 
            List<ScheduleEntity> listofSchedules = new List<ScheduleEntity>();

            List<MTC.Common.DTO.Schedule> schedules = MTC.Business.Schedule.Schedule.GetASchedule(scheduleDate, shiftId);
            foreach (Common.DTO.Schedule schedule in schedules) 
            {
                ScheduleEntity entity = new ScheduleEntity();
                entity.DriverId = schedule.DriverId;
                entity.FirstName = schedule.FirstName;
                entity.LastName = schedule.LastName;
                entity.PlateNumber = schedule.PlateNumber;
                entity.ScheduleDate = schedule.ScheduleDate;
                entity.ScheduleId = schedule.ScheduleId;
                entity.ShiftDescription = schedule.ShiftDescription;
                entity.ShiftId = schedule.ShiftId;
                entity.TaxiId = schedule.TaxiId;
                entity.ScheduleDriverTaxiId = schedule.ScheduleDriverTaxiId;
                listofSchedules.Add(entity);
            }

            return listofSchedules;
        }


        public bool DeleteASchedule(DateTime scheduleDate, int shiftId, int ScheduleDriverTaxiId)
        {
            return MTC.Business.Schedule.Schedule.DeleteSchedule(scheduleDate, shiftId);
        }

        public bool DeleteASchedule(DateTime scheduleDate, int shiftId)
        {
            return MTC.Business.Schedule.Schedule.DeleteSchedule(scheduleDate, shiftId);
        }

        //public MTC.Common.DTO.Schedule GetASchedule(DateTime dateOfSchedule, int shiftId)
        //{
        //    return MTC.Business.Schedule.Schedule.GetASchedule(dateOfSchedule, shiftId);
        //}

        public List<Common.DTO.Schedule> CreateASchedule(DateTime schedule, int shift)
        {
            return MTC.Business.Schedule.Schedule.CreateASchedule(schedule, shift);
        }

        public bool UpdateASchedule(int ScheduleDriverTaxiId, int DriverId)
        {
            return MTC.Business.Schedule.Schedule.UpdateASchedule(ScheduleDriverTaxiId, DriverId);
        }


        public bool CheckSchedule(DateTime schedule, int shift)
        {
            return MTC.Business.Schedule.Schedule.CheckSchedule(schedule, shift);
        }
    }

    }

